home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / btrieve / btr61m.exe / 10CH5B.TXT < prev    next >
Text File  |  1993-07-16  |  32KB  |  984 lines

  1. CHAPTER 5       USING BTRIEVE UTILITIES (continued)
  2.  
  3.  
  4. Concepts
  5.  
  6. The following paragraphs describe concepts you should
  7. understand before using the Maintenance utility
  8. commands.
  9.  
  10. Filenames
  11.  
  12. The Maintenance utility runs as an NLM.  The NLM
  13. environment does not recognize drive letters or
  14. environment variables.  Thus, for commands that
  15. require a filename, the name must include the full
  16. pathname, such as SYS:\NWSQL\DEMODATA\PATIENTS.DTA.  If
  17. you do not specify a volume, the utility assumes SYS:
  18. is the volume.
  19.  
  20. Owner Names
  21.  
  22. Btrieve allows you to restrict access to a file by
  23. specifying an owner name.  Since owner names are
  24. optional, the files you use with this utility may or
  25. may not require an owner name.
  26.  
  27. If the file requires an owner name, you must specify
  28. it using the /O option.  (Alternatively, you can use a
  29. dash with this option, as in -O.) Owner names are case
  30. sensitive; that is, Sandy and SANDY are not considered
  31. to be the same.  You can follow the /O option with an
  32. owner name or an asterisk (*).  If you use an
  33. asterisk, the utility prompts you for an owner name.
  34.  
  35. Description Files
  36.  
  37. A description file is an ASCII file containing
  38. information that the Maintenance utility commands
  39. CREATE, INDEX, and SINDEX need to perform their
  40. operations.  Description files contain one or more
  41. elements.
  42.  
  43. An element consists of a keyword, followed by an equal
  44. sign (=), followed by a value (with no space
  45. separator).  Each element in the description file
  46. corresponds to a particular characteristic of a Btrieve
  47. file or key definition.  Appendix A, "Description
  48. Files," provides more information.
  49.  
  50. Continuous Operation
  51.  
  52. Continuous operation is a Btrieve feature that allows
  53. you to back up files while they are in use by Btrieve
  54. applications.  Two Maintenance utility commands,
  55. STARTBU and ENDBU, begin and end continuous operation
  56. on a file or set of files.
  57.  
  58. When continuous operation begins, Btrieve creates a
  59. temporary Btrieve file (called a delta file) for each
  60. data file in order to record any changes made to the
  61. data file while the backup is taking place.  This
  62. temporary delta file may surpass the size of the
  63. original data file if users make extensive changes to
  64. the file during continuous operation.
  65.  
  66. When continuous operation ends, Btrieve updates the
  67. master Btrieve files with the changes stored in the
  68. delta files.  Btrieve deletes the delta files as soon
  69. as all applications close the corresponding Btrieve
  70. data files.
  71.  
  72. NOTE:  As indicated above, when you place a Btrieve
  73. file into continuous operation mode, Btrieve creates a
  74. temporary delta file with the same name as the data
  75. file but with a .^^^ extension.  Therefore, do not
  76. create multiple Btrieve files with the same names but
  77. different extensions.  For example, do not use a
  78. naming scheme such as INVOICE.HDR and INVOICE.DET for
  79. your Btrieve files.
  80.  
  81. To back up files using continuous operation, first
  82. issue the BUTIL -STARTBU command, followed by the file
  83. or set of files.  Next, run your backup program.  To
  84. stop continuous operation, issue the BUTIL -ENDBU
  85. command.
  86.  
  87. SUGGESTION:  The best time to place Btrieve data files
  88. into continuous operation for backup is when the fewest
  89. users will be making modifications to the files.
  90.  
  91.  
  92. Command Files
  93.  
  94. You can use a command file to do either
  95. of the following:
  96.  
  97. o Execute a command that is too long to fit on the
  98.   command line
  99.  
  100. o Execute a command that you use often (by entering
  101.   the command once in the command file and then
  102.   executing the command file as often as you want)
  103.  
  104. Command files contain the same information as that
  105. required on the command line.
  106.  
  107. Rules for Command Files
  108. Observe the following rules when creating a
  109. Maintenance utility command file:
  110.  
  111. o You must limit each line to 130 characters.
  112.  
  113.   NOTE:  Lines longer than 130 characters could cause
  114.   the server to end abnormally.  For this reason, do not
  115.   place long Maintenance utility commands in a server
  116.   command (.NCF) file.
  117.  
  118. o You cannot split a single parameter across two lines.
  119.  
  120. o You can specify only one command per command file.
  121.  
  122.  
  123. Command File Example
  124.  
  125. The following is an example command file,
  126. COPYPATS.CMD.  The file calls the BUTIL -CLONE command
  127. to clone the file PATIENTS.DTA.
  128.  
  129.    -CLONE
  130.        sys:\nwsql\demodata\allpats.dta
  131.        sys:\nwsql\demodata\patients.dta
  132.  
  133. The following command uses the COPYPATS.CMD file:
  134.  
  135.    LOAD BUTIL @sys:\nwsql\demodata\copypats.cmd
  136.  
  137.  
  138. Maintenance Utility Commands
  139.  
  140. This section describes the Maintenance utility
  141. commands and explains when and how to use each one.
  142. At any time while using the Maintenance utility
  143. commands, you can enter LOAD BUTIL to see the
  144. Maintenance utility commands.  The utility responds
  145. with the following screen.
  146.  
  147.  
  148. CLONE
  149.  
  150. The CLONE command creates a new, empty Btrieve file
  151. with the same file specifications as an existing file
  152. (including any supplemental indexes, but excluding the
  153. owner name).  The new Btrieve file includes all the
  154. defined key characteristics (such as key position, key
  155. length, or duplicate key values) contained in the
  156. existing file.
  157.  
  158. Format
  159.  
  160.   LOAD BUTIL -CLONE
  161.      outputBtrvFile sourceBtrvFile [/Oowner]
  162.  
  163.   outputBtrvFile The full pathname you want to use for
  164.          the new, empty Btrieve file.
  165.  
  166.   sourceBtrvFile The full pathname of the existing
  167.          Btrieve file that you want to
  168.          replicate.
  169.  
  170.   owner      The owner name, if any, for the source
  171.          Btrieve file.    The new Btrieve file will
  172.          not have an owner name.
  173.  
  174. Remarks
  175.  
  176. Btrieve v6.x allows a maximum of 23 key segments in a
  177. Btrieve file with a page size of 1,024 bytes.
  178. Therefore, the CLONE command sets the page size in the
  179. new Btrieve file to 2,048 bytes if the existing
  180. Btrieve file contains 24 key segments and has a page
  181. size of 1,024 bytes.  This occurs if the existing
  182. Btrieve file has a format earlier than Btrieve v6.0
  183. and the Btrieve NLM was not loaded with the Create
  184. Btrieve Files in Pre v6.x Format configuration option.
  185.  
  186. Example
  187.  
  188. The following command creates the NEWAPP.DTA file by
  189. cloning the PATIENTS.DTA file.
  190.  
  191.    LOAD BUTIL -CLONE
  192.       sys:\nwsql\demodata\newapp.dta
  193.       sys:\nwsql\demodata\patients.dta
  194.  
  195. SUGGESTION:  If you are trying to recover from
  196. receiving Status Code 30 and you suspect that the
  197. header page of the source file might be damaged, try
  198. creating the new Btrieve file by using the BUTIL
  199. -CREATE command with a description file.
  200.  
  201.  
  202. CLROWNER
  203.  
  204. The CLROWNER command clears the owner name of
  205. a Btrieve file.
  206.  
  207. Format
  208.  
  209.   LOAD BUTIL -CLROWNER btrvFile /Oowner
  210.  
  211.   btrvFile The full pathname of the Btrieve file.
  212.  
  213.   owner    The owner name to be cleared.
  214.  
  215. Example
  216.  
  217. The following command clears the owner name for the
  218. PATIENT1.DTA file.  The owner name for the file is
  219. Sandy.
  220.  
  221.    LOAD BUTIL -CLROWNER
  222.       sys:\nwsql\demodata\patient1.dta /OSandy
  223.  
  224.  
  225. COPY
  226.  
  227. The COPY command copies the contents of one Btrieve
  228. file to another.  COPY retrieves each record in the
  229. input Btrieve file and inserts it into the output
  230. Btrieve file.  The record size must be the same in both
  231. files.  After copying the records, COPY displays the
  232. total number of records inserted into the new Btrieve
  233. file.
  234.  
  235. NOTE:  COPY performs in a single step the same
  236. function as a RECOVER command followed by a LOAD
  237. command.
  238.  
  239. By using the COPY command, you can create a Btrieve
  240. file that contains data from an old file, but has new
  241. key characteristics.  To do so, proceed as follows:
  242.  
  243. 1.  Use the CREATE command to create an empty Btrieve
  244. file with the desired key characteristics (key
  245. position, key length, or duplicate key values).
  246.  
  247. 2.  Use the COPY command to copy the contents of the
  248. existing Btrieve file into the newly created Btrieve
  249. file.
  250.  
  251. Format
  252.  
  253.   LOAD BUTIL -COPY inputBtrvFile
  254.      outputBtrvFile [/Oowner1 [/Oowner2] ]
  255.  
  256.   inputBtrvFile  The full pathname of the Btrieve file
  257.          from which you want to transfer records.
  258.  
  259.   outputBtrvFile The full pathname of the Btrieve file
  260.          into which you want to insert records.
  261.          The output Btrieve file can contain data
  262.          or be empty.
  263.  
  264.   owner1     The owner name of the input
  265.          Btrieve file, if required.  If only the
  266.          output Btrieve file requires an owner
  267.          name, specify /O followed by a blank
  268.          for owner1 (as illustrated in the
  269.          example).
  270.  
  271.   owner2     The owner name of the output Btrieve
  272.          file, if required.
  273.  
  274. Example
  275.  
  276. The following command copies the records in
  277. PATIENTS.DTA to NEWPATS.DTA.  The PATIENTS.DTA input
  278. file does not require an owner name, but the
  279. NEWPATS.DTA output file uses the owner name Pam.
  280.  
  281.    LOAD BUTIL -COPY
  282.       sys:\nwsql\demodata\patients.dta
  283.       sys:\nwsql\demodata\newpats.dta /O /OPam
  284.  
  285. If you omit the first /O from this example, the
  286. utility assumes that the owner name Pam belongs to the
  287. input Btrieve file, not the output Btrieve file.
  288.  
  289.  
  290. CREATE
  291.  
  292. The CREATE command generates an empty Btrieve file
  293. using the characteristics you specify in a description
  294. file.
  295.  
  296. Before you can use the CREATE command, you must create
  297. a description file to specify the new key
  298. characteristics.  For more information, see Appendix
  299. A, "Description Files."
  300.  
  301. Format
  302.  
  303. LOAD BUTIL -CREATE btrvFile descriptionFile
  304.  
  305.   btrvFile      The full pathname of the Btrieve file
  306.           you want to create.  If the pathname is
  307.           the name of an existing Btrieve file,
  308.           this command creates a new, empty
  309.           Btrieve file in place of the existing
  310.           Btrieve file.  Any data that was stored
  311.           in the existing Btrieve file is lost and
  312.           cannot be recovered.    However, Btrieve
  313.           does not create a new Btrieve file if
  314.           you specify replace=n in the
  315.           description file.  (For an example, see
  316.           "Replace Existing File" in Appendix A.)
  317.  
  318.   descriptionFile The full pathname of the description
  319.           file containing the specifications for
  320.           the new Btrieve file.
  321.  
  322. Example
  323.  
  324. The following command creates a Btrieve file named
  325. PATIENTS.DTA using the description provided in the
  326. BUILD.DES description file.
  327.  
  328.    LOAD BUTIL -CREATE
  329.       sys:\nwsql\patients.dta sys:\nwsql\build.des
  330.  
  331. Sample Description File for the CREATE Command
  332.  
  333. The sample description file shown in the following
  334. illustration creates a Btrieve file.  The Btrieve file
  335. is specified to have a page size of 512 bytes and 2
  336. keys.  The fixed-length portion of each record in the
  337. Btrieve file is set to 98 bytes.  Variable-length
  338. records with no blank truncation, data compression, and
  339. Variable-tail Allocation Tables (VATs) are specified.
  340. The free space threshold is set to 20 percent.
  341. Allocation is set to 100 pages.  Btrieve will
  342. preallocate 100 pages, or 51,200 bytes, when it
  343. creates the Btrieve file.
  344.  
  345. ---------------------------------------------------------------------------
  346.  record=98 variable=y truncate=n compress=y  ---+
  347.  key=2 page=512 allocation=100 replace=n    | File Specifications
  348.  fthreshold=20 huge=y                        ---+
  349.  
  350.  position=1 length=5 duplicates=y            ---+ Key 0
  351.  modifiable=n type=string alternate=y           | Segment 1
  352.  null=y value=20 segment=y                   ---+
  353.  
  354.  position=6 length=10 duplicates=y           ---+ Key 0
  355.  modifiable=n type=string alternate=y           | Segment 2
  356.  null=y value=20 segment=n                   ---+
  357.  
  358.  position=16 length=2 duplicates=n           ---+ Key 1
  359.  modifiable=y type=numeric descending=y         |
  360.  alternate null=n segment=n                  ---+
  361.  
  362.  name=path/upper.alt
  363. --------------------------------------------------------------------------
  364.  
  365.  
  366. Key 0 is a segmented key with two duplicatable,
  367. nonmodifiable string segments and a null value of 20
  368. hexadecimal (space) specified for both segments.  Key
  369. 0 uses the collating sequence UPPER.ALT.
  370.  
  371. Key 1 is a numeric, nonsegmented key that does not
  372. allow duplicates but permits modification.  It is
  373. sorted in descending order.
  374.  
  375.  
  376. DROP
  377.  
  378. The DROP command removes an index from a Btrieve file
  379. and adjusts the key numbers of any remaining indexes,
  380. subtracting 1 from each subsequent key number.  If you
  381. do not want to renumber the keys, you can add 128 to
  382. the key number you specify to be dropped.  This
  383. renumbering feature is available only for Btrieve v6.x
  384. files.
  385.  
  386. Format
  387.  
  388.   LOAD BUTIL -DROP btrvFile keyNumber [/Oowner]
  389.  
  390.   btrvFile   The full pathname of the Btrieve
  391.          file from which you are dropping the index.
  392.  
  393.   keyNumber  The number of the index you want to remove.
  394.          If you want to preserve the original key
  395.          numbers, add a 128 bias to the key number
  396.          you specify.
  397.  
  398.   owner      The owner name for the Btrieve file, if required.
  399.  
  400. Examples
  401.  
  402. In both of the following examples, PATIENTS.DTA has
  403. three keys.  The original keys in the file were
  404. numbered 0, 1, and 2.
  405.  
  406. In the first example, the BUTIL -DROP command drops
  407. key number 1 from the PATIENTS.DTA file and renumbers
  408. the remaining key numbers as 0 and 1.
  409.  
  410.    LOAD BUTIL -DROP sys:\nwsql\demodata\patients.dta 1
  411.  
  412. In the following example, the BUTIL -DROP command drops
  413. key number 1 and does not renumber the keys.  The key
  414. numbers remain 0 and 2.
  415.  
  416.    LOAD BUTIL -DROP
  417.       sys:\nwsql\demodata\patients.dta 129
  418.  
  419.  
  420. ENDBU
  421.  
  422. The ENDBU command ends continuous operation on a
  423. Btrieve file or set of Btrieve files previously
  424. defined for backup.  Execute this command after you
  425. have issued the STARTBU command and your backup
  426. utility has finished running.  (For more information
  427. on the STARTBU command, see "STARTBU." For more
  428. information on continuous operation, see "Continuous
  429. Operation.")
  430.  
  431. To back up Btrieve files using continuous operation,
  432. first issue the LOAD BUTIL ╨STARTBU command, followed
  433. by the Btrieve file or set of Btrieve files.  Next,
  434. run your backup program.  Then, stop continuous
  435. operation by issuing the LOAD BUTIL -ENDBU command.
  436.  
  437. NOTE:  When you place a Btrieve file into continuous
  438. operation mode, Btrieve creates a temporary delta file
  439. with the same name as the Btrieve data file, but with
  440. a .^^^ extension.  Therefore, do not create multiple
  441. Btrieve files with the same names but different
  442. extensions.  For example, do not use a naming scheme
  443. such as INVOICE.HDR and INVOICE.DET for your Btrieve
  444. files.
  445.  
  446. Format
  447.  
  448.   LOAD BUTIL -ENDBU [btrvFile | @filename]
  449.  
  450.   btrvFile  The full pathname of the Btrieve
  451.         file for which you want to end continuous
  452.         operation.
  453.  
  454.   @filename The name of a text file containing a list of
  455.         Btrieve files for which you want to end
  456.         continuous operation.  The text file must
  457.         contain the full pathname for each Btrieve
  458.         file, and you must separate these pathnames
  459.         with a space or a carriage return/line feed.
  460.         Typically, this list of Btrieve files is the
  461.         same as the list used with the STARTBU
  462.         command.
  463.  
  464. If you do not specify any Btrieve files with the LOAD
  465. BUTIL -ENDBU command, the utility stops continuous
  466. operation on all Btrieve files initialized by BUTIL
  467. -STARTBU and currently running in continuous operation
  468. mode.
  469.  
  470. Example
  471.  
  472. The following example ends continuous operation on the
  473. PATIENTS.DTA file.
  474.  
  475.    LOAD BUTIL -ENDBU
  476.       sys:\nwsql\demodata\patients.dta
  477.  
  478.  
  479. INDEX
  480.  
  481. The INDEX command builds an external index file for an
  482. existing Btrieve file, based on a field not previously
  483. specified as a key in the existing file.  Before you
  484. can use the INDEX command, you must create a
  485. description file to specify the new key
  486. characteristics.  (For more information on description
  487. files, see Appendix A, "Description Files.")
  488.  
  489. The external index file created is a key-only Btrieve
  490. file.  The records in the new file consist of the
  491. following:
  492.  
  493. o The 4-byte address of each record in the existing
  494.   Btrieve file
  495.  
  496. o The new key value on which you want to sort
  497.  
  498. NOTE:  If the key length you specify in the description
  499. file is 10 bytes, the record length of the external
  500. index file would be 14 bytes (10 plus the 4-byte
  501. address).
  502.  
  503. Format
  504.  
  505.   LOAD BUTIL -INDEX btrvFile indexFile
  506.      descriptionFile [/Oowner]
  507.  
  508.   btrvFile    The full pathname of the existing Btrieve file
  509.           for which you want to build an external
  510.           index.
  511.  
  512.   indexFile   The full pathname of the index file in which
  513.           Btrieve should store the external index.
  514.  
  515.    descriptionFile The full pathname of the description file you
  516.           have created containing the new key
  517.           definition. The description file should
  518.           contain a definition for each segment of
  519.           the new key.
  520.  
  521.   owner       The owner name for the Btrieve file, if
  522.           required.
  523.  
  524. Remarks
  525.  
  526. The INDEX command creates the external index file and
  527. then displays the number of records that were
  528. indexed.  If you want to retrieve the Btrieve file's
  529. records using the external index file, use the SAVE
  530. command (described in "SAVE").
  531.  
  532. Sample Description File for the INDEX Command
  533.  
  534. The description file shown in the following
  535. example defines a new key with one segment.  The
  536. key begins at byte 30 of the record and is 10 bytes
  537. long.  It allows duplicates, is modifiable, is a string
  538. type, and uses no alternate collating sequence.
  539.  
  540.    position=30 length=10 duplicates=y modifiable=y
  541.    type=string alternate=n segment=n
  542.  
  543. Example
  544.  
  545. The following command creates an external index file
  546. called NEWPAT.IDX using a Btrieve file called
  547. PATIENTS.DTA.  The PATIENTS.DTA file does not require
  548. an owner name.  The description file containing the
  549. definition for the new key is called NEWIDX.DES.
  550.  
  551.    LOAD BUTIL -INDEX
  552.       sys:\nwsql\demodata\patients.dta
  553.       sys:\nwsql\demodata\newpat.idx
  554.       sys:\nwsql\demodata\newidx.des
  555.  
  556. NOTE:  When you place a Btrieve file into continuous
  557. operation mode, Btrieve creates a temporary delta file
  558. with the same name as the data file, but with a .^^^
  559. extension.  Therefore, do not create multiple Btrieve
  560. files with the same names but different extensions.
  561. For example, do not use a naming scheme such as
  562. INVOICE.HDR and INVOICE.DET for your Btrieve files.
  563.  
  564.  
  565. LOAD
  566.  
  567. The LOAD command inserts records from an input
  568. sequential file into a Btrieve file.  LOAD performs no
  569. conversion on the data in the input sequential file.
  570. After the utility transfers the records to the Btrieve
  571. file, it displays the total number of records loaded.
  572.  
  573. Before running the LOAD command, you must create the
  574. input sequential file and the Btrieve file.  You can
  575. create the input sequential file using a standard text
  576. editor or an application; the input sequential file
  577. must have the required file format (as explained
  578. subsequently).  You can create the Btrieve file using
  579. either BUTIL -CREATE or BUTIL -CLONE.
  580.  
  581. Format
  582.  
  583.   LOAD BUTIL -LOAD inputFile btrvFile
  584.      [/Oowner]
  585.  
  586.   inputFile  The full pathname of the ASCII sequential
  587.          file containing the records to be loaded
  588.          into a Btrieve file.
  589.  
  590.   btrvFile   The full pathname of the Btrieve file into
  591.          which you want to insert the records.
  592.  
  593.   owner      The owner name for the Btrieve file, if required.
  594.  
  595. Required File Format
  596.  
  597. Records in the input sequential file must be in the
  598. following format:
  599.  
  600. o The first field must be a left-adjusted integer (in
  601.   ASCII) that provides the length of the record.  This
  602.   field does not include the carriage return or line
  603.   feed.
  604.  
  605.   For files with fixed-length records, the length you
  606.   specify should equal the record length of the Btrieve
  607.   file.
  608.  
  609.   For files with variable-length records, the length
  610.   you specify must be at least as long as the minimum
  611.   fixed length of the Btrieve file.
  612.  
  613. o A separator (either a comma or a blank) must follow
  614.   the length field.
  615.  
  616. o The record data follows the separator.  The length
  617.   of the data must be the exact number of bytes
  618.   specified by the length field.
  619.  
  620. o A carriage return/line feed (0D0A hexadecimal) must
  621.   terminate each line.  The carriage return/line feed
  622.   is not included in the length value at the beginning
  623.   of the line, and LOAD does not insert the carriage
  624.   return/line feed into the Btrieve file.
  625.  
  626. o The last line in the file must consist of the
  627.   end-of-file character (Ctrl+Z or 1A hexadecimal).
  628.   The SAVE and RECOVER commands and most text editors
  629.   automatically insert this character in the file.
  630.  
  631.   You can create an input sequential file using either
  632.   a text editor or an application, as follows:
  633.  
  634. o If you use a text editor to create the input
  635.   sequential file, pad each record with blank spaces as
  636.   necessary to fill the record to the length you
  637.   specified at the beginning of the record.  Fields
  638.   containing binary data cannot be edited with most
  639.   text editors.
  640.  
  641. o If you use an application to create the input
  642.   sequential file, append a carriage return/line feed
  643.   to the end of each record and include an end-of-file
  644.   character (Ctrl+Z or 1A hexadecimal) as the last line
  645.   in the file.  The sequential I/O calls provided by
  646.   most high-level language processors insert carriage
  647.   return, line feed, and end-of-file characters
  648.   automatically.
  649.  
  650. The following illustration shows the correct format
  651. for records in the input sequential file.  For this
  652. example, the Btrieve file has a defined record length
  653. of 40 bytes.
  654.  
  655.  
  656.    40, The record follows the comma delimiter   <CR/LF>
  657.    | | |____________________________________| |    |
  658.    | |                 Data                   |    |__Carriage Return
  659.    | |                                        |       or Line Feed
  660.    | |__Comma Delimiter                       |__Blank Pad
  661.    |____Record Length                            for Proper Length
  662.  
  663.  
  664. Example
  665.  
  666. The following example loads sequential records from the
  667. PATIENTS.ADR file into the PATIENTS.DTA file.  The
  668. owner name of the PATIENTS.ADR file is Sandy.
  669.  
  670.    LOAD BUTIL -LOAD
  671.       sys:\nwsql\demodata\patients.adr
  672.       sys:\nwsql\demodata\patients.dta /OSandy
  673.  
  674.  
  675. RECOVER
  676.  
  677. The RECOVER command extracts data from a Btrieve file
  678. and places it in a sequential file that has the same
  679. format as the input sequential file used by the LOAD
  680. command.  This is often useful for extracting some or
  681. all of the data from a damaged Btrieve file.  The
  682. RECOVER command may be able to retrieve many, if not
  683. all, of the file's records.  You can then use the LOAD
  684. command to insert the recovered records into a new,
  685. undamaged Btrieve file.
  686.  
  687. NOTE:  The Maintenance utility performs no conversion
  688. on the data in the records.  Therefore, if you use a
  689. text editor to modify an output file containing binary
  690. data, be aware that some text editors may change the
  691. binary data, causing the results to be unpredictable.
  692.  
  693. The RECOVER command performs the following actions:
  694.  
  695. o Checks the file's Page Allocation Table (PAT) and
  696.   reconstructs it, if users request this.  The PAT is
  697.   the part of the Btrieve file that maintains a map of
  698.   each page's physical location.
  699.  
  700. o Reads records in physical order from the Btrieve
  701.   file, using Btrieve Step operations.
  702.  
  703. o Creates a sequential file that is compatible with the
  704.   required format for the LOAD command.  (See "Required
  705.   File Format" for more information about the format.)
  706.  
  707. o Displays the total number of recovered records.
  708.  
  709. Format
  710.  
  711.   LOAD BUTIL -RECOVER btrvFile outputFile
  712.      [/Oowner]
  713.  
  714.   btrvFile   The full pathname of the Btrieve file from
  715.          which you want to recover data.
  716.  
  717.   outputFile The full pathname of the ASCII sequential
  718.          file where the utility should store the
  719.          recovered records.
  720.  
  721.   owner      The owner name for the Btrieve file, if
  722.          required.
  723.  
  724. Remarks
  725.  
  726. If the file's PAT is damaged, a prompt similar to the
  727. following appears:
  728.  
  729.    The file's Page Allocation Table seems to be
  730.    damaged.
  731.    BUTIL *strongly* recommends that you make a
  732.    backup copy before continuing.
  733.    Continue? 1=Yes 2=No
  734.  
  735. By default, the prompt displays 2 (indicating No) on
  736. the next line.  This allows you to exit the RECOVER
  737. command and back up the Btrieve file before
  738. proceeding.  If you have already backed up the Btrieve
  739. file, enter 1 to continue running the RECOVER command.
  740.  
  741. The RECOVER command allows you to set the Btrieve
  742. file's page size.  It displays the following prompt:
  743.  
  744.    Enter the page size or 0 to quit:  512
  745.  
  746. The value displayed at this prompt is the result of an
  747. attempt to determine the original page size of the
  748. Btrieve file.  If this value is incorrect, enter the
  749. correct page size.  If you enter a page size that
  750. differs from the original page size, the result is
  751. unpredictable.  If you are unsure of the correct page
  752. size, change the value as prompted by the utility.
  753.  
  754. If the logical disk drive containing your output
  755. sequential file becomes full before the entire Btrieve
  756. file has been recovered, the utility stops, indicates
  757. the number of records already recovered, and displays
  758. the following prompt:
  759.  
  760.    The disk volume is full.
  761.    Enter new file name to continue or a period
  762.    to quit.
  763.  
  764. To continue running the RECOVER command using an
  765. additional output sequential file, complete one of the
  766. following steps:
  767.  
  768. o If you are recovering the Btrieve file to diskettes,
  769.   remove the full diskette and replace it with another
  770.   formatted diskette.
  771.  
  772. o If you are recovering the Btrieve file to a hard
  773.   disk, specify another logical disk drive that has
  774.   space available.
  775.  
  776. In either case, enter the full pathname of the Btrieve
  777. file you want to use to continue storing records, and
  778. then press the Enter key.  The utility continues
  779. copying records from the Btrieve file to the new
  780. output sequential file.  This process creates multiple
  781. sequential files that you must load separately with
  782. the LOAD command.
  783.  
  784. If the RECOVER command receives a variable page error
  785. (Status Code 54), it places all the data it can obtain
  786. from the current record in the output sequential file
  787. and continues the recovery process.
  788.  
  789. Upon completion, the utility displays a message
  790. similar to the following:
  791.  
  792.    16 records recovered.
  793.    Operation completed successfully.
  794.  
  795. Example
  796.  
  797. The following example extracts records from the
  798. PATIENTS.DTA file and writes them into the SEQPAT.DAT
  799. file.
  800.  
  801.    LOAD BUTIL -RECOVER
  802.       sys:\nwsql\patients.dta
  803.       sys:\nwsql\seqpat.dat
  804.  
  805.  
  806. SALVAGE
  807.  
  808. The SALVAGE command examines the records in a file's
  809. PAT to determine if corruption has occurred.  (The PAT
  810. maintains a map of the physical location of each page
  811. in the Btrieve file.) If corruption has occurred, the
  812. utility asks if you want to repair the PAT.
  813.  
  814. Format
  815.  
  816.   LOAD BUTIL -SALVAGE btrvFile [/Oowner]
  817.  
  818.   btrvFile The full pathname of the Btrieve file
  819.        containing the records you want to check.
  820.  
  821.   owner    The owner name for the Btrieve file, if
  822.        required.
  823.  
  824. Remarks
  825.  
  826. If the file's PAT is damaged, the utility reminds you
  827. that you should have a backup of the Btrieve file
  828. before proceeding and asks if you want to repair the
  829. file now.  If you have already backed up the Btrieve
  830. file, enter Y (for Yes).  If you have not backed up the
  831. Btrieve file, enter N (for No).
  832.  
  833. After you enter Y, the utility asks you to enter a
  834. page size and provides you with the result of its
  835. attempt to determine the original page size.  If you
  836. suspect that the value shown is incorrect, enter a new
  837. value.  The utility then attempts to repair the
  838. Btrieve file, using the new value.  If the utility
  839. cannot repair the Btrieve file, it sends a message
  840. identifying the reason why.
  841.  
  842. NOTE: The SALVAGE command does not save the records to
  843. a sequential file.
  844.  
  845.  
  846. SAVE
  847.  
  848. The SAVE command retrieves records from a Btrieve file
  849. using a specified index path and places them in a
  850. sequential file that is compatible with the required
  851. format for the LOAD command.  You can then edit the
  852. sequential file and use the LOAD command to store the
  853. edited data in another Btrieve file.  (See "LOAD" for
  854. more information about LOAD.)
  855.  
  856. SAVE generates a single record in the output
  857. sequential file for each record in the input Btrieve
  858. file.  Upon completion, SAVE displays the total number
  859. of records saved.
  860.  
  861. NOTE:  The Maintenance utility performs no conversion
  862. on the data in the records.  Therefore, if you use a
  863. text editor to modify an output file containing binary
  864. data, be aware that some text editors may change the
  865. binary data, causing the results to be unpredictable.
  866.  
  867. Format
  868.  
  869.   LOAD BUTIL -SAVE btrvFile outputFile
  870.      [Y indexFile | N keyNumber] [/Oowner]
  871.  
  872.   btrvFile   The full pathname of the Btrieve file
  873.          containing the records you want to save.
  874.  
  875.   outputFile The full pathname of the ASCII sequential
  876.          file in which you want the utility to store
  877.          the records.
  878.  
  879.   indexFile  The full pathname of an external index file
  880.          by which you want to save records if you do
  881.          not want to save records using the default
  882.          of the lowest key number.
  883.  
  884.   keyNumber  The key number (other than 0) by which you
  885.          want to save records if you do not want to
  886.          save records using the default of the lowest
  887.          key number.  owner The owner name for the
  888.          Btrieve file, if required.
  889.  
  890. Remarks
  891.  
  892. If the logical disk drive containing your output
  893. sequential file becomes full before the entire Btrieve
  894. file has been saved, the utility stops, indicates the
  895. number of records already saved, and displays the
  896. following message:
  897.  
  898.    The disk volume is full.
  899.    Enter new file name to continue or a period
  900.    to quit.
  901.  
  902. To continue the SAVE operation in another output
  903. sequential file, complete one of the following steps:
  904.  
  905. o If you are saving the Btrieve file to diskettes,
  906.   remove the full diskette and replace it with another
  907.   formatted diskette.
  908.  
  909. o If you are saving the Btrieve file to a hard disk,
  910.   specify another logical disk drive that has space
  911.   available.
  912.  
  913. In either case, enter the full pathname of the Btrieve
  914. file you want to use to continue storing records, and
  915. press the Enter key.  The utility continues copying
  916. records from the Btrieve file to the new output
  917. sequential file.  Keep in mind that this process
  918. creates multiple sequential files that you must load
  919. separately with the LOAD command.
  920.  
  921. Examples
  922.  
  923. The following two examples illustrate how to use the SAVE
  924. command to retrieve records from a Btrieve file.
  925.  
  926. The first example uses the NEWPAT.IDX external index
  927. file to retrieve records from the PATIENTS.DTA file
  928. and store them in an unformatted text file called
  929. PATIENTS.SAV:
  930.  
  931.    LOAD BUTIL -SAVE
  932.       sys:\nwsql\demodata\patients.dta
  933.       sys:\nwsql\demodata\patients.sav
  934.       sys:\nwsql\demodata\newpat.idx
  935.  
  936. The next example retrieves records from the
  937. PATIENTS.DTA file using key number 3 and stores them
  938. in an unformatted text file called PATIENTS.SAV:
  939.  
  940.    LOAD BUTIL -SAVE
  941.       sys:\nwsql\demodata\patients.dta
  942.       sys:\nwsql\demodata\patients.sav N 3
  943.  
  944.  
  945. SETOWNER
  946.  
  947. The SETOWNER command creates an owner for a Btrieve
  948. file.
  949.  
  950. Format
  951.  
  952.   LOAD BUTIL -SETOWNER btrvFile /Oowner level
  953.  
  954.   btrvFile The full pathname of the Btrieve file.
  955.  
  956.   owner    The owner name to be set.
  957.  
  958.   level    The type of access restriction for the Btrieve
  959.        file.  The possible values for this parameter
  960.        are as follows:
  961.  
  962.        0 Requires an owner name for any access mode
  963.          (no data encryption)
  964.  
  965.        1 Permits read access without an owner name
  966.          (no data encryption)
  967.  
  968.        2 Requires an owner name for any access mode
  969.          (with data encryption)
  970.  
  971.        3 Permits read access without an owner name
  972.          (with data encryption)
  973.  
  974. Example
  975.  
  976. The following example cretaes an owner for the
  977. PATIENTS.DTA file. The owner name is Sandy, and
  978. the restriction level is 1.
  979.  
  980.    LOAD BUTIL -SETOWNER
  981.       sys:\nwsql\demodata\patients.dta\OSandy 1
  982.  
  983.  
  984.